package com.egame.manage.biz.web.controller.gc;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

import cn.egame.common.servlet.WebUtils;
import cn.egame.interfaces.pu.AppParameter;

import com.egame.manage.biz.server.ManageClient;
import com.egame.manage.biz.web.controller.BaseController;
import com.lenovo.manager.business.domain.UserBean;

@Controller
@RequestMapping("store/manage")
public class ManageStoreController extends BaseController{

	public ManageStoreController() {
	}
	
	public ManageStoreController(HttpServletRequest req, HttpServletResponse resp){
		super(req, resp);
	}
	
	@RequestMapping(value = "/list/navigate", method = {RequestMethod.GET,RequestMethod.POST})
	public ModelAndView listStoreManageChannel(HttpServletRequest req, HttpServletResponse resp)throws Exception{
		if(req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY) != null){
			UserBean userBean = (UserBean) req.getSession().getAttribute(com.egame.manage.biz.utils.ConstVar.USER_SESSION_KEY);
			loginUserId = userBean.getOperatorId();
		}
		ModelAndView mav = new ModelAndView("/new/navigate"); 
		//首页
		int parentId1 = WebUtils.getInt(req, "parentId", 132);
		List<Integer> channerlIdsIntegers1 = ManageClient.getInstance().listAppParameterIdsByParentId(appId, loginUserId, parentId1);
		List<AppParameter> list1 = ManageClient.getInstance().listAppParameterByIds(appId, loginUserId, channerlIdsIntegers1); 
		mav.addObject("listChannel1", list1);
		//应用
		int parentId2 = WebUtils.getInt(req, "parentId", 133);
		List<Integer> channerlIdsIntegers2 = ManageClient.getInstance().listAppParameterIdsByParentId(appId, loginUserId, parentId2);
		List<AppParameter> list2 = ManageClient.getInstance().listAppParameterByIds(appId, loginUserId, channerlIdsIntegers2); 
		mav.addObject("listChannel2", list2);
		//游戏
		int parentId3 = WebUtils.getInt(req, "parentId", 134);
		List<Integer> channerlIdsIntegers3 = ManageClient.getInstance().listAppParameterIdsByParentId(appId, loginUserId, parentId3);
		List<AppParameter> list3 = ManageClient.getInstance().listAppParameterByIds(appId, loginUserId, channerlIdsIntegers3); 
		mav.addObject("listChannel3", list3);
		//导航
		int parentId4 = WebUtils.getInt(req, "parentId", 135);
		List<Integer> channerlIdsIntegers4 = ManageClient.getInstance().listAppParameterIdsByParentId(appId, loginUserId, parentId4);
		List<AppParameter> list4 = ManageClient.getInstance().listAppParameterByIds(appId, loginUserId, channerlIdsIntegers4); 
		mav.addObject("listChannel4", list4);
		//装机
		int parentId5 = WebUtils.getInt(req, "parentId", 136);
		List<Integer> channerlIdsIntegers5 = ManageClient.getInstance().listAppParameterIdsByParentId(appId, loginUserId, parentId5);
		List<AppParameter> list5 = ManageClient.getInstance().listAppParameterByIds(appId, loginUserId, channerlIdsIntegers5); 
		mav.addObject("listChannel5", list5);
		
		return mav;
	}
}
